from selenium import webdriver
from selenium.webdriver.chrome.options import Options

class DriverUtils:
    __driver = None

    @classmethod
    def get_driver(cls):
        if cls.__driver is None:
            # 新版推荐：用 Options 配置，也可按需添加参数（如无头模式）
            options = Options()
            # 示例：添加无头模式（可选，根据需求决定是否开启）
            # options.add_argument('--headless=new')  
            cls.__driver = webdriver.Chrome(options=options)  
            cls.__driver.maximize_window()
            cls.__driver.implicitly_wait(10)
        return cls.__driver

    @classmethod
    def quit_driver(cls):
        if cls.__driver is not None:
            import time
            time.sleep(3)
            cls.__driver.quit()
            cls.__driver = None